package com.example.cloudpracticeplatform.service.impl;

import com.example.cloudpracticeplatform.entity.Teacher;
import com.example.cloudpracticeplatform.mapper.TeacherMapper;
import com.example.cloudpracticeplatform.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TeacherServiceImpl implements TeacherService {

    @Autowired
    private TeacherMapper teacherMapper;

    @Override
    public int register(Teacher teacher) {
        return teacherMapper.insert(teacher);
    }

    @Override
    public Teacher login(String username, String password) {
        Teacher teacher = teacherMapper.findByUsername(username);
        if (teacher != null && teacher.getPassword().equals(password)) {
            return teacher;
        }
        return null;
    }

    @Override
    public Teacher findById(Integer teacherId) {
        return teacherMapper.findById(teacherId);
    }
}